package com.ebao.po.qa;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.ebao.constants.UserType;

/**
 * @desc 问题
 * @author snow
 * @date 2012-7-6
 */
@Entity
@Table(name = "T_Question")
public class TQuestion implements Serializable {

	private static final long serialVersionUID = -8420004475899658786L;
	
	private Long id;				// 问题Id
	private TTopic topic;			// 所属话题
	private String title;			// 问题标题
	private String content;			// 问题内容
	private UserType userType;		// 用户类型user/doctor
	private String referId;			// 用户Id
	private String createTime;		// 问题创建时间
	private Integer viewAmount;		// 该问题浏览次数
	private List<TAnswer> answers = new ArrayList<TAnswer>();			// 问题的回答
	private Set<TConcernQA> concernUsers = new HashSet<TConcernQA>();	// 关注该问题的user/doctor
//	private List<TTag> tags = new ArrayList<TTag>();					// 问题标签,单向由TTag到TQuestion
	
	@Id
	@GeneratedValue
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getReferId() {
		return referId;
	}

	public void setReferId(String referId) {
		this.referId = referId;
	}

	public UserType getUserType() {
		return userType;
	}

	public void setUserType(UserType userType) {
		this.userType = userType;
	}

	@Column(length = 18)
	public String getCreateTime() {
		return createTime;
	}

	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}

	public Integer getViewAmount() {
		return viewAmount;
	}

	public void setViewAmount(Integer viewAmount) {
		this.viewAmount = viewAmount;
	}

	@ManyToOne(optional = false, targetEntity = TTopic.class)
	@JoinColumn(name = "topic_id")
	public TTopic getTopic() {
		return topic;
	}

	public void setTopic(TTopic topic) {
		this.topic = topic;
	}

	@OneToMany(cascade = {CascadeType.ALL}, mappedBy = "question", targetEntity = TAnswer.class)
	public List<TAnswer> getAnswers() {
		return answers;
	}

	public void setAnswers(List<TAnswer> answers) {
		this.answers = answers;
	}

	@OneToMany(mappedBy = "question", targetEntity = TConcernQA.class)
	public Set<TConcernQA> getConcernUsers() {
		return concernUsers;
	}

	public void setConcernUsers(Set<TConcernQA> concernUsers) {
		this.concernUsers = concernUsers;
	}
	
}
